<?php

/**

 * 数据库操作类

 */

class DBUtil {

const bbyscm_card = 'bbyscm_card';

const bbyscm_card_formid = 'bbyscm_card_formid';

const bbyscm_card_videosetup = 'bbyscm_card_videosetup';

const bbyscm_card_banner = 'bbyscm_card_banner';

const bbyscm_card_sysset = 'bbyscm_card_sysset';

const bbyscm_card_message = 'bbyscm_card_message';

const bbyscm_card_indus = 'bbyscm_card_indus';

const bbyscm_card_mails = 'bbyscm_card_mails';

const bbyscm_card_mail = 'bbyscm_card_mail';

const bbyscm_card_gun = 'bbyscm_card_gun';

const bbyscm_card_gunsetup = 'bbyscm_card_gunsetup';

const bbyscm_card_pay = 'bbyscm_card_pay';

const bbyscm_card_wxacode = 'bbyscm_card_wxacode';

const bbyscm_card_mailacode = 'bbyscm_card_mailacode';

const bbyscm_card_mailsetup = 'bbyscm_card_mailsetup';

const bbyscm_card_cityclass = 'bbyscm_card_cityclass';

const bbyscm_card_citybanner = 'bbyscm_card_citybanner';

const bbyscm_card_cityxinxi = 'bbyscm_card_cityxinxi';

const bbyscm_card_tabbar = 'bbyscm_card_tabbar';

const bbyscm_card_tabbar_list = 'bbyscm_card_tabbar_list';

const bbyscm_card_chain_banner = 'bbyscm_card_chain_banner';

const bbyscm_card_chains = 'bbyscm_card_chains';


	//总数

	public function getCount($table, $where, $params) {

		return pdo_fetchcolumn('SELECT COUNT(*) AS `number` FROM ' . tablename($table) . ' WHERE ' . $where, $params);

	}

	//列表

	public function getMany($table, $where, $params, $order = '', $page = 1, $pagesize = 0, $op = 'AND') {

		$sql = 'SELECT * FROM ' . tablename($table) . ' WHERE ' . $where;

		if (!empty($order)) {

			$sql .= ' ORDER BY ' . $order;

		}

		if (!empty($pagesize)) {

			$sql .= ' LIMIT ' . ($page - 1) * $pagesize . ',' . $pagesize;

		}

		return pdo_fetchall($sql, $params, $op);

	}

	//单个

	public function getOne($table, $where, $params, $op = 'AND') {

		return pdo_fetch('SELECT * FROM ' . tablename($table) . ' WHERE ' . $where, $params, $op);

	}

	//修改

	public function update($table, $data, $params, $op = 'AND') {

		return pdo_update($table, $data, $params, $op);

	}

	//新增

	public function save($table, $data) {

		return pdo_insert($table, $data);

	}

	//删除

	public function delete($table, $params, $op = 'AND') {

		return pdo_delete($table, $params, $op);

	}

}

?>